﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HDJ.Framework.Core
{
  public   class TableTypeSupprotEnum : TableTypeSupprotObjectBase
    {
        public override List<string> TypeCategory => new List<string>() { "enum" };
        public override bool IsEnum => true;
        public TableTypeSupprotEnum(Dictionary<Type, TableTypeSupportBase> baseTypeSupports) : base(baseTypeSupports)
        {

        }
        public override object GetTypeDefultValue(Type type)
        {
            Array array = Enum.GetValues(type);
            object obj = array.GetValue(0);
            return obj;
        }
        protected override string Object2String(object value)
        {
            return value.ToString();
        }

       new public object TableStringData2Value(Type type, string data)
        {
            if (string.IsNullOrEmpty(data))
                return GetTypeDefultValue(type);

            return String2Object(type,data);
        }
        protected override object String2Object(Type type,string data)
        {
            return  Enum.Parse(type, data);;
        }
    }
}
